<?php

/* 
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Home\Controller;
use OT\DataDictionary;

class RantalController extends HomeController {

//系统首页
public function index(){
$data=M('Screening');
$info=$data->find(1);
$area=explode(",",$info['area']);
$widespread=explode(",",$info['widespread']);
$type=explode(",",$info['type']);
$floor=explode(",",$info['floor']);
$price=  explode(",", $info['price']);
$this->assign('area', $area);
$this->assign('widespread', $widespread);
$this->assign('type', $type);
$this->assign('floor', $floor);
$this->assign('price',$price);



$this->display('rantal');
}
public function update(){
 $time = $_POST['time'];
$status = $_POST['status'];
$type = '出租';
$categoryid = 58;
$data= array();
if(!isset($time,$status))
{
    $categoryid = 59;
    $type='出售';
    $time= '出售不填';
    $status ='出售不填';
    
}
$data['title']=$_POST['range'].$_POST['status'].$_POST['types'].$type;
$data['street']=$_POST['street'];
$data['range'] = $_POST['range'];
$data['house_type']=$_POST['huxing'].'室'.$_POST['ting'].'廳'.$_POST['ce'].'廁';
$data['types'] =$_POST['types'];
$data['floor'] = $_POST['floors'];
$data['address'] = $_POST['add'];
$data['foregift'] = $_POST['foregift'];
$data['description'] = $_POST['description'];
$data['statused'] = $status;
$data['wname'] = $_POST['name'];
$data['tel'] = $_POST['tel'];
$data['email'] = $_POST['email'];
$data['adds'] = $_POST['adds'];
$data['photo'] =$_POST['pics']; 
$data['rantaltime'] = $time;
$data['fee'] = $_POST['fee'];
$data['finish'] =$_POST['finish'];
$data['device']=$_POST['devices'];
$data['area'] = $_POST['area'];
$data['category_id']=$categoryid;
$data['uid']=1;
$data['pid']=0;
$data['model_id']=10;
$data['type']=2;
$data['status'] =1; 
$data['create_time']=  time();
$data['update_time']=time();
$res = D('Document')->updates($data);
if(!$res){
$this->error(D('Document')->getError());
}else{

$this->success($res['id']?'更新成功':'發佈成功', Cookie('__forward__'));

 
}                    



}
}